package com.lt.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lt.entity.Medicine;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface MedicineDao extends BaseMapper<Medicine> {

    @Insert("insert into tb_medicine values (null,#{name},#{type},#{address},#{number},#{price});")
    int save(Medicine medicine);

    @Delete("delete from tb_medicine where medicine_id = #{id};")
    int deleteById(Integer id);

    @Update("update tb_medicine set medicine_name=#{name},medicine_type=#{type},medicine_address=#{address}," +
            "medicine_number=#{number},medicine_price=#{price} where medicine_id=#{id};")
    int update(Medicine medicine);

    @Select("select medicine_id as id, medicine_name as name,medicine_type as type," +
            "medicine_address as address,medicine_number as number, medicine_price as price from tb_medicine")
    List<Medicine> getAll();

    @Select("select medicine_id as id,medicine_name as name,medicine_type as type," +
            "medicine_address as address,medicine_number as number," +
            " medicine_price as price from tb_medicine where medicine_id = #{id}")
    Medicine getById(Integer id);

}
